package main

import (
	"github.com/gorhill/cronexpr"
	"time"
)

func main(){

	var (
		ch chan *CronJob
	)

	ch = make(chan *CronJob, 10)

	register := NewRegister(ch)

	var expr = cronexpr.MustParse("*/5 * * * * * *")
	var cronJob = &CronJob{
		name: "job1",
		expr: expr,
		nextTime: expr.Next(time.Now()),
	}

	register.DoRegister(cronJob)
	//otherJob := cronJob.Clone()
	//register.DoRegister(&otherJob)


	scheduler := NewScheduler(register)

	go scheduler.Doloop()


	for {

		for job  := range ch {
			job.Exec()
		}

	}

}